import request from '@/utils/request'
import type { LoginForm } from '@/types/user';
// 登录接口
export const login = async (data:LoginForm) => {
        return request({
          url: 'auths/login',
          method: 'post',
          data
        }) 
  };

  // 校验验证码
  export const verifyCode=async (code:string) => {
    return request({
      url: 'auths/verifyCode/' + code,
      method: 'post'
    })
  }

  // 获取用户信息
  export const getUserInfo = async () => {

    return request({
      url: 'auths/userInfo',
      method: 'get'
    })
 
        //return {
         // code: 200,
         // data: {
          //  name: 'Admin',
          //  roles: ['admin'],
           // permissions: ['user:add', 'user:edit']
         // }
       // }
      
  };

  /**
   * 注册接口
   */
  export const registerApi = async (data: any) => {
    return request({
      url: 'auths/register',
      method: 'post',
      data
    })
  }


  /**
   * 跟新登录用户头像
   */
  export const updateUserAvatarApi = async (avatar: string) => {
    return request({
      url: 'auths/updateUserAvatar',
      method: 'post',
      data: {
        avatar
      }
    })
  }